package com.feather.common.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author flogyin
 */
public interface RequestEnvironment extends ArgumentCustom {
	static final RequestEnvironment[]	CURRENT	= new RequestEnvironment[] { new RequestEnvironment() {

													@Override
													public void custom(HttpServletRequest request, Map<String, Object> argument) {

													}

													@Override
													public void custom(HttpSession session, Map<String, Object> argument) {

													}

													@Override
													public String getRequestEncoding(HttpServletRequest request) {
														return "UTF-8";
													}

													@Override
													public String getUploadTempDir(HttpServletRequest request) {
														return System.getProperty("java.io.tmpdir");
													}

													@Override
													public int getUploadBuffer(HttpServletRequest request) {
														return -1;
													}

													@Override
													public int getUploadMaxSize(HttpServletRequest request) {
														return -1;
													}

													@Override
													public void notFoundName(Object obj, String name) {

													}

													@Override
													public void notFoundValue(HttpServletRequest request, KeyName name, String value) {

													}

													@Override
													public Object getLoginObject(HttpSession session) {
														return null;
													}

													@Override
													public String getLoginInfo(HttpSession session, String name) {
														return "";
													}

													@Override
													public void setLoginObject(HttpSession session, Object object) {

													}

													@Override
													public void removeLoginObject(HttpSession session) {

													}

													@Override
													public String getLoginInfo(Object object, String name) {
														return null;
													}

													@Override
													public boolean isSA(HttpSession session) {
														return false;
													}

													@Override
													public boolean isSA(Object object) {
														return false;
													}

													@Override
													public boolean hasLogin(HttpSession session) {
														return false;
													}

													@Override
													public boolean hasPermission(HttpSession session, String code) {
														return false;
													}

													@Override
													public String getPermissionName(HttpServletRequest request, String code) {
														return null;
													}

													@Override
													public Map<String, String> getCacheMap(HttpServletRequest request, String prefix, String code) {
														return null;
													}

													@Override
													public String getCacheDictionaryPrefix(HttpServletRequest request) {
														return null;
													}

													@Override
													public List<Map<String, String>> getCacheDictionary(HttpServletRequest request, String dicNode) {
														return null;
													}

													@Override
													public int[] getMediaThumbnailSize(HttpServletRequest request) {
														return null;
													}

													@Override
													public long thumbnailMedia(Map<String, Object> args, int tw, int th, XFileItem xFileItem) throws Exception {
														return -1L;
													}

													@Override
													public String[] getImageFormatSuffix() {
														return null;
													}

													@Override
													public String[] getVideoFormatSuffix() {
														return null;
													}

													@Override
													public String pagination(Object data) {
														return "";
													}

													@Override
													public List<Integer> getYearNearby(String year) {
														return null;
													}

													@Override
													public List<Integer> getYearNearby(int year) {
														return null;
													}
												} };

	// Encoding
	String getRequestEncoding(HttpServletRequest request);

	// Upload
	String getUploadTempDir(HttpServletRequest request);

	int getUploadBuffer(HttpServletRequest request);

	int getUploadMaxSize(HttpServletRequest request);

	// not found name
	void notFoundName(Object obj, String name);

	void notFoundValue(HttpServletRequest request, KeyName name, String value);

	// login
	Object getLoginObject(HttpSession session);

	String getLoginInfo(HttpSession session, String name);

	void setLoginObject(HttpSession session, Object object);

	void removeLoginObject(HttpSession session);

	String getLoginInfo(Object object, String name);

	boolean isSA(HttpSession session);

	boolean isSA(Object object);

	boolean hasLogin(HttpSession session);

	boolean hasPermission(HttpSession session, String code);

	String getPermissionName(HttpServletRequest request, String code);

	// cache
	Map<String, String> getCacheMap(HttpServletRequest request, String prefix, String code);

	String getCacheDictionaryPrefix(HttpServletRequest request);

	List<Map<String, String>> getCacheDictionary(HttpServletRequest request, String dicNode);

	// media
	int[] getMediaThumbnailSize(HttpServletRequest request);

	long thumbnailMedia(Map<String, Object> args, int tw, int th, XFileItem xFileItem) throws Exception;

	String[] getImageFormatSuffix();

	String[] getVideoFormatSuffix();

	// util
	String pagination(Object data);

	List<Integer> getYearNearby(String year);

	List<Integer> getYearNearby(int year);
}
